package com.privatetime.dao.impl;

import java.util.List;

import com.privatetime.dao.UserDao;
import com.privatetime.model.User;

public class UserDaoImpl extends BaseDaoImpl<User, Integer> implements UserDao {

	public User userLogin(String userName, String passWord) {
		StringBuffer sql = new StringBuffer();
		sql
				.append("select user from User user where user.userName=? and user.passWord=?");
		User loginUser = findEntityUnique(sql.toString(), new Object[] {
				userName, passWord });
		logger.info("User is " + loginUser);
		return loginUser;
	}

	public List<User> queryUserByGroup(Integer groupId) {
		StringBuffer sql = new StringBuffer();		
		sql.append("select user from User user join user.groupSet groups where groups.id=?");
		List<User> users = findEntityList(sql.toString(), groupId);		
		return users;
	}


}